Skip to content

Fix #250: Replace form type object with classname string #253

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 4 commits into from

Conversation

bocharsky-bw
Copy link
Contributor

No description provided.

@javiereguiluz
Copy link
Member

@bocharsky-bw thanks for this fix ... but I'm afraid I have bad news for you 😢 This project is compatible with php >=5.3.9 so we can't use the ::class trick and we must use the entire fully qualified class name of the form types.

@bocharsky-bw
Copy link
Contributor Author

For now, but when we update to the Symfony 3 we should use 5.5.9 at least, right? It will work then.

@javiereguiluz
Copy link
Member

Yes.

@bocharsky-bw
Copy link
Contributor Author

So keep it as is or update with fully qualified classname?

@javiereguiluz
Copy link
Member

Good question. I'd prefer to use the full string because that works perfectly on 2.8 and 3.0 ... but in the future we'll need to change it again to make code more concise.

@voronkovich
Copy link
Contributor

@bocharsky-bw, you forgot to update form type's classes too. See https://github.com/symfony/symfony-demo/blob/master/src/AppBundle/Form/PostType.php

@bocharsky-bw
Copy link
Contributor Author

@javiereguiluz You're right. I updated with fully qualified classname for now.

@bocharsky-bw
Copy link
Contributor Author

@voronkovich Did you mean this https://github.com/symfony/symfony-demo/blob/master/src/AppBundle/Form/PostType.php#L64 ? Seems for now we should use fully qualified classnames, but thanks you pointed it!

@voronkovich
Copy link
Contributor

@bocharsky-bw, ok.

@stof
Copy link
Member

stof commented Nov 18, 2015

You should also switch to FQCN rather than legacy type names inside the existing form types to avoid deprecation warnings there

@stof
Copy link
Member

stof commented Nov 18, 2015

@javiereguiluz this requires bumping the Symfony requirement to ~2.8 though. Currently, the code still says ~2.7

@bocharsky-bw
Copy link
Contributor Author

Switched. Thanks @stof !

@@ -31,7 +31,7 @@ services:
app.form.type.datetimepicker:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@bocharsky-bw now we needn't this service. You can remove it.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@bocharsky-bw, because in the PostType we use FQCN.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hm, it's true. Thanks!

@yceruto
Copy link
Member

yceruto commented Nov 20, 2015

This comment is not related to this PR. But IMHO these changes are a throwback for developers. :(

@@ -43,13 +43,13 @@ public function buildForm(FormBuilderInterface $builder, array $options)
'attr' => array('autofocus' => true),
'label' => 'label.title',
))
->add('summary', 'textarea', array('label' => 'label.summary'))
->add('content', 'textarea', array(
->add('summary', 'Symfony\Component\Form\Extension\Core\Type\TextareaType', array('label' => 'label.summary'))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This summary field is a string type, why use textarea? or perhaps we should redefine it as text?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it doesn't necessary to change it to text... Even with 255 length more convenient work with textarea.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@bocharsky-bw then, when users to type a text with 256 characters or more will be truncated and this could be an unexpected result for the user. I suggest then use maxlength 255 for this widget.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

max_length is deprecated option

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@voronkovich I meant to the html attribute:

'attr' => array('maxlength' => 255)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@yceruto, ok.

@javiereguiluz
Copy link
Member

@bocharsky-bw thanks for working on this. I'm merging it because I want to release a Symfony 2.8-based demo app soon. Thanks!

@bocharsky-bw bocharsky-bw deleted the form-type branch December 10, 2015 14:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants